/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.login.plugin.accountBind;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.RelativeLayout.LayoutParams;
import com.qihoo.gamecenter.sdk.login.plugin.accountBind.view.VerifyPhoneNumberDialog;
import com.qihoo.gamecenter.sdk.login.plugin.accountBind.view.VerifyPhoneNumberDialogLandscape;
import com.qihoo.gamecenter.sdk.login.plugin.accountBind.view.VerifyPhoneNumberDialogPayPopup;
import com.qihoo.gamecenter.sdk.login.plugin.accountBind.view.VerifyPhoneNumberDialogPopup;
import com.qihoo.gamecenter.sdk.login.plugin.accountBind.view.VerifyProgress;
import com.qihoo.gamecenter.sdk.login.plugin.accountBind.view.VerifySMSCodeDialog;
import com.qihoo.gamecenter.sdk.login.plugin.accountBind.view.VerifySMSCodeDialogPopup;
import com.qihoo.gamecenter.sdk.login.plugin.accountBind.view.b;
import com.qihoo.gamecenter.sdk.login.plugin.component.ResizeRelativeLayout;
import com.qihoo.gamecenter.sdk.login.plugin.d.a;
import com.qihoo.gamecenter.sdk.login.plugin.h.e;
import com.qihoo.gamecenter.sdk.login.plugin.h.f;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;

public class a implements b {
    private Intent b;
    private String c;
    private Activity d;
    public ResizeRelativeLayout a;
    private LinearLayout e;
    private VerifyPhoneNumberDialog f;
    private VerifySMSCodeDialog g;
    private VerifyProgress h;
    private int i = 0;
    private boolean j = false;
    private boolean k;
    private int l = 3;

    public a(Context paramContext, Intent paramIntent) {
        this.d = ((Activity) paramContext);
        this.b = paramIntent;
        this.b = paramIntent;
        this.c = this.b.getStringExtra("insdk_version");
        this.j = paramIntent.getBooleanExtra("is_from_login", false);
        this.k = this.b.getBooleanExtra("screen_orientation", true);
    }

    public View a(int paramInt) {
        this.l = paramInt;
        this.a = new ResizeRelativeLayout(this.d);
        this.a.setId(com.qihoo.gamecenter.sdk.login.plugin.accountBind.view.a.b.ordinal());
        this.a.setLayoutParams(new RelativeLayout.LayoutParams(-1, -1));
        RelativeLayout.LayoutParams localLayoutParams = new RelativeLayout.LayoutParams(-2, -2);
        localLayoutParams.addRule(13);
        this.e = new LinearLayout(this.d);
        this.e.setLayoutParams(localLayoutParams);
        this.a.addView(this.e);
        a();
        return this.a;
    }

    public void a() {
        b();
        c();
        d();
        e();
        this.d.getWindow().setSoftInputMode(18);
        a(1, null);
    }

    private void b() {}

    private void c() {
        this.h = new VerifyProgress(this.d, this.c);
        this.h.setBackgroundDrawable(null);
        this.h.a();
        this.a.addView(this.h);
    }

    private void d() {
        if ((this.k) && (this.l == 3))
            this.f = new VerifyPhoneNumberDialogLandscape(this.d, this.c, this.b, this);
        else if (this.l == 3)
            this.f = new VerifyPhoneNumberDialog(this.d, this.c, this.b, this);
        else if (this.l == 2)
            this.f = new VerifyPhoneNumberDialogPayPopup(this.d, this.c, this.b, this);
        else
            this.f = new VerifyPhoneNumberDialogPopup(this.d, this.c, this.b, this);
        this.f.setVerifyProgress(this.h);
        this.f.setTipText(com.qihoo.gamecenter.sdk.login.plugin.d.a(d.a.dE));
    }

    private void a(Map paramMap) {
        if (this.f == null)
            d();
        this.e.removeAllViews();
        this.e.addView(this.f, new LinearLayout.LayoutParams(-1, -2));
        this.f.a(paramMap);
    }

    private void e() {
        if (this.l == 2)
            this.g = new VerifySMSCodeDialogPopup(this.d, this.c, this.b, this);
        else
            this.g = new VerifySMSCodeDialog(this.d, this.c, this.b, this);
        this.g.setVerifyProgress(this.h);
    }

    private void b(Map paramMap) {
        if (this.g == null)
            e();
        this.e.removeAllViews();
        this.e.addView(this.g, new LinearLayout.LayoutParams(-1, -2));
        this.g.a(paramMap);
    }

    public void a(int paramInt, Map paramMap) {
        a(paramInt, -1, paramMap);
    }

    public void a(int paramInt1, int paramInt2, Map paramMap) {
        f.a(this.d);
        switch (paramInt1) {
        case 0:
            break;
        case 1:
            f();
            break;
        case 2:
            a(null);
            break;
        case 3:
            if (this.f != null)
                this.f.f();
            break;
        case 4:
            b(paramMap);
            break;
        case 5:
            if (this.g != null)
                this.g.d();
            break;
        case 6:
            break;
        case 7:
            com.qihoo.gamecenter.sdk.login.plugin.accountBind.a.a.a(this.d,
                    com.qihoo.gamecenter.sdk.login.plugin.h.d.d(), false);
            com.qihoo.gamecenter.sdk.common.c localc1 = (com.qihoo.gamecenter.sdk.common.c) this.d;
            String str;
            if (paramMap != null)
                str = f.a(Integer.valueOf((String) paramMap.get("errno")).intValue(), (String) paramMap.get("errmsg"));
            else
                str = f.a(400, "http request exception");
            if (this.f != null)
                this.f.d();
            if (this.g != null)
                this.g.b();
            localc1.execCallback(str.toString());
            this.d.finish();
            break;
        case 8:
            boolean bool1 = com.qihoo.gamecenter.sdk.login.plugin.profile.a.b(this.d,
                    com.qihoo.gamecenter.sdk.login.plugin.h.d.d());
            boolean bool2 = com.qihoo.gamecenter.sdk.login.plugin.profile.a.a(this.d,
                    com.qihoo.gamecenter.sdk.login.plugin.h.d.d());
            com.qihoo.gamecenter.sdk.common.c localc2 = (com.qihoo.gamecenter.sdk.common.c) this.d;
            if ((bool1) || (bool2)) {
                localc2.execCallback(null);
            }
            else {
                JSONObject localJSONObject = new JSONObject();
                try {
                    localJSONObject.put("modify_headshot", this.j);
                    localc2.execCallback(localJSONObject.toString());
                } catch (JSONException localJSONException) {
                    e.b("BindPhoneManager",
                            "contruct modify headshot json object " + localJSONException.getLocalizedMessage());
                    localc2.execCallback(null);
                }
            }
            this.d.finish();
        }
        this.i = paramInt1;
    }

    private void f() {
        a(2, null);
    }

    public void a(c paramc) {
        if (this.f != null)
            this.f.a(paramc);
        if (this.g == null)
            return;
        this.g.a(paramc);
    }
}